//
//  ViewController.m
//  FKNetWorking
//
//  Created by 云眼科技 on 16/7/16.
//  Copyright © 2016年 CloudEyes. All rights reserved.
//

#import "FKMainViewController.h"
#import "UIViewController+FKAdd.h"
#import "FKGetTableViewController.h"
#import "FKPostTableViewController.h"
#import "FKDownloadTableViewController.h"
#import "FKUploadTableViewController.h"
#import "NSObject+FKAdd.h"


@interface FKMainViewController ()<UITableViewDelegate, UITableViewDataSource>

//http://www.yunyankeji.com:1222/dzy/Link/resource/6938888888615.zip

@property (nonatomic, strong) UITableView *myTableView;
@property (nonatomic, strong) NSMutableArray <__kindof UIViewController *> *dataArray;

@end

#ifndef W_H_
#define kWidth [UIScreen mainScreen].bounds.size.width
#define kHeight [UIScreen mainScreen].bounds.size.height
#endif

static NSString *const fk_MainViewController_title = @"Demo";
static NSString *const identifiler = @"FKNetworkingDemoCell";


@implementation FKMainViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = fk_MainViewController_title;
    [self fk_setTranslucentNO];
    [self.view addSubview:self.myTableView];
}


#pragma mark - tableView delegate
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    [self fk_animationPushViewController:self.dataArray[indexPath.row]];
}

#pragma mark - tableView datasource
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.dataArray.count;
}


-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifiler];
    
    
    cell.textLabel.text = self.dataArray[indexPath.row].title;
    return cell;
}


#pragma mark - getters
-(UITableView *)myTableView{
    if (!_myTableView) {
        _myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kWidth, kHeight) style:UITableViewStylePlain];
        _myTableView.delegate = self;
        _myTableView.dataSource = self;
        _myTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
        [_myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:identifiler];
    }
    return _myTableView;
}

-(NSMutableArray <UIViewController *> *)dataArray{
    if (!_dataArray) {
        _dataArray = [[NSMutableArray alloc]init];
        
        FKGetTableViewController      *getVC      = [[FKGetTableViewController      alloc] init];
        FKPostTableViewController     *postVC     = [[FKPostTableViewController     alloc] init];
        FKDownloadTableViewController *downloadVC = [[FKDownloadTableViewController alloc] init];
        FKUploadTableViewController   *uploadVC   = [[FKUploadTableViewController   alloc] init];
        
        getVC.title      = @"FKNetworkingGetTest";
        postVC.title     = @"FKNetworkingPostTest";  
        downloadVC.title = @"FKNetworkingDownloadTest";
        uploadVC.title   = @"FKNetworkingUploadTest";
        [_dataArray addObject:getVC];
        [_dataArray addObject:postVC];
        [_dataArray addObject:downloadVC];
        [_dataArray addObject:uploadVC];
    }
    return _dataArray;
}


@end
